#include<iostream>
#include<algorithm>
using namespace std;
const int N=1e6+10;

int shuwei(int n){
    int n1=0;
    while(n){
        n1=n1+n%10;
        n/=10;
    }
    return n1;
}

bool cmp(int a,int b){
    int n1=shuwei(a);
    int n2=shuwei(b);
    if(n1==n2)return a<b;
    else return n1<n2;
}

int a[N];
int main(){
    int n,m;
    scanf("%d",&n);
    scanf("%d",&m);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    sort(a,a+n,cmp);
    cout<<a[m-1];
    
    return 0;
}
